package com.viknix.threadpool.manager.cluster.file;

import java.io.Serializable;

/**
 * @Author: Dongqi
 * @Date: 2021/11/16 15:58
 * @Version 1.0
 * @Description: 文件系统变更事件
 */
public class FileChangeEvent implements Serializable {

    private static final long serialVersionUID = -4255584033113954765L;

    /**
     * 该变更事件涉及的文件路径
     */
    private String paths;

    /**
     * 该变更事件的上下文
     */
    private Object context;

    public static FileChangeEventBuilder builder() {
        return new FileChangeEventBuilder();
    }

    public String getPaths() {
        return paths;
    }

    public void setPaths(String paths) {
        this.paths = paths;
    }

    public Object getContext() {
        return context;
    }

    public void setContext(Object context) {
        this.context = context;
    }

    @Override
    public String toString() {
        return "FileChangeEvent{" + "paths='" + paths + '\'' + ", context=" + context + '}';
    }

    public static final class FileChangeEventBuilder {

        private String paths;

        private Object context;

        private FileChangeEventBuilder() {
        }

        public FileChangeEventBuilder paths(String paths) {
            this.paths = paths;
            return this;
        }

        public FileChangeEventBuilder context(Object context) {
            this.context = context;
            return this;
        }

        /**
         * build FileChangeEvent.
         *
         * @return {@link FileChangeEvent}
         */
        public FileChangeEvent build() {
            FileChangeEvent fileChangeEvent = new FileChangeEvent();
            fileChangeEvent.setPaths(paths);
            fileChangeEvent.setContext(context);
            return fileChangeEvent;
        }
    }
}
